package cn.rongdao.jrkabao.ui.IdentificationVerificate.IdentificationWithValidationItem;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.mifengkong.frtools.ui.activity.FRStartActivity;

import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.constant.InfoConstant;
import cn.rongdao.jrkabao.dao.FundAndActivityCenterUrlDao;
import cn.rongdao.jrkabao.ui.webview.WebViewActivity4Fund;

import static cn.rongdao.jrkabao.ui.webview.WebViewActivity4Fund.WEBVIEWACTIVITY4FUND_RTURN;


/**
 * Created by jiangyongxing on 2017/9/19.
 * 描述：
 */

public class IdentificationWithFublicFundActivity extends IdentificationWithValidationItemActivity {

    private String mCateId;
    private String mProductId;
    private String mPageSource;
    private String loanName;

    public static void start(Context context, String cateId, String productId, String pageSource, String loanName) {
        Bundle bundle = new Bundle();
        bundle.putString(InfoConstant.CATE_ID, cateId);
        bundle.putString(InfoConstant.PRODUCT_ID, productId);
        bundle.putString(InfoConstant.PAGE_SOURCE, pageSource);
        bundle.putString(InfoConstant.LOAN_NAME, loanName);
        FRStartActivity.start(context, IdentificationWithFublicFundActivity.class, bundle);
    }

    @Override
    protected void initView() {
        super.initView();
        mCateId = getIntent().getStringExtra(InfoConstant.CATE_ID);
        mProductId = getIntent().getStringExtra(InfoConstant.PRODUCT_ID);
        mPageSource = getIntent().getStringExtra(InfoConstant.PAGE_SOURCE);
        loanName = getIntent().getStringExtra(InfoConstant.LOAN_NAME);

        mValidationItemUIComponent.setTitle("第二步  公积金验证");
        titleBarUIComponent.initTitleBlack("公积金验证");
        mValidationItemUIComponent.setContent(R.drawable.icon_public_fund, "登录公积金账户", "请登录本人的公积金账户");
        mValidationItemUIComponent.setSubmitOnclickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                WebViewActivity4Fund.startWithPageSource(getActivity(), FundAndActivityCenterUrlDao.getInstance().queryObject().getPublic_fund_url(), mProductId, mPageSource, loanName);
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //公积金导入成功了，跳转到大额贷或者是小额贷的时候，这个页面可以直接关闭了
        if (resultCode == WEBVIEWACTIVITY4FUND_RTURN)
            finish();
    }
}
